package com.zmsoft.boxy.sfg.api;

import javax.annotation.Resource;

import org.cnsoft.framework.beans.common.RESTResultBean;
import org.cnsoft.framework.beans.user.UserBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cnsoft.material.IMaterialConstants;
import com.zmsoft.boxy.sfg.MySFGControllerSupport;
import com.zmsoft.boxy.sfg.player.BoxySFGPlayer;
import com.zmsoft.boxy.sfg.service.SFGGameInteractService;

/**
 * 玩家之间动作接口
 * 
 * @version 1.0.0 2014/11/19
 * @since 1.0.0 2014/11/19
 */
@Controller
//@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@RequestMapping(value = "/game/1.0/sfg/interact")
public class SFGGameInteractApiController extends MySFGControllerSupport implements IMaterialConstants {

	@Resource
	private SFGGameInteractService mySFGGameInteractService;
	
	/**
	 * 加好友
	 */
	@RequestMapping(value = "/friend.js", method = RequestMethod.POST)
	@ResponseBody
	public RESTResultBean<UserBean> doInteractFriend(BoxySFGPlayer toPlayer) throws Exception {
		return mySFGGameInteractService.doPlayerFriend(toPlayer);
	}
	
	/**
	 * 浇水
	 */
	@RequestMapping(value = "/watering.js", method = RequestMethod.POST)
	@ResponseBody
	public RESTResultBean<UserBean> doInteractWatering(BoxySFGPlayer toPlayer) throws Exception {
		return mySFGGameInteractService.doCropsWatering(toPlayer);
	}

	/**
	 * 除草
	 */
	@RequestMapping(value = "/weed.js", method = RequestMethod.POST)
	@ResponseBody
	public RESTResultBean<UserBean> doInteractWeed(BoxySFGPlayer toPlayer) throws Exception {
		return mySFGGameInteractService.doCropsWeed(toPlayer);
	}

	/**
	 * 杀虫
	 */
	@RequestMapping(value = "/insecticidal.js", method = RequestMethod.POST)
	@ResponseBody
	public RESTResultBean<UserBean> doInteractInsecticidal(BoxySFGPlayer toPlayer) throws Exception {
		return mySFGGameInteractService.doCropsInsecticidal(toPlayer);
	}

	/**
	 * 偷取果实
	 */
	@RequestMapping(value = "/steal.js", method = RequestMethod.POST)
	@ResponseBody
	public RESTResultBean<UserBean> doInteractSteal(BoxySFGPlayer toPlayer) throws Exception {
		return mySFGGameInteractService.doStealFruit(toPlayer);
	}
}
